package com.zhixi.pattern.important.singletonpattern.operation;

/**
 * 懒汉式（多线程）
 *
 *
 * @作者 ShuHaoNan
 * @邮箱 shuhaonan1@gmail.com
 * @时间 2020/11/15 9:33
 */
public class Singleton5 {

    private static Singleton5 instance;

    private Singleton5() {}

    // 多线程（不安全）
    public static synchronized Singleton5 getInstance() {
        if (instance == null) {
            synchronized (Singleton5.class) {
                instance = new Singleton5();
            }
        }
        return instance;
    }

}
